package com.alfayun.fiscalriskanalysis.analysisspec;

import java.util.Collection;
import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.alfayun.fiscalriskanalysis.indicatorspec.IndicatorSpec;
import com.alfayun.fiscalriskanalysis.util.TagsConverter;

@Entity
@Table(name = "analysis_spec")
public final class AnalysisSpec {
	
	@Column(name = "analysis_spec_id", updatable = false)
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Id
	private Integer id;
	public String name;
	@Convert(converter = TagsConverter.class)
	public Set<String> tags;
	
	@ManyToMany
	private List<IndicatorSpec> indicators;
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	public String getTags() {
		return TagsConverter.joinSet(tags);
	}

	public void setTags(String tags) {
		this.tags = TagsConverter.splitString(tags);
	}

	public Collection<IndicatorSpec> getAllIndicator() {
		return indicators;
	}
	
}
